import java.util.Arrays;

/**
 * 按既定顺序创建数组
 *
 * @USER: Administrator
 * @DATE: 2024/9/28 上午10:59
 * @VERSION: 1.0.0
 */
public class LC1389 {
    public static void main(String[] args) {

    }

    public int[] createTargetArray(int[] nums, int[] index) {
        int[] res = new int[nums.length];
        Arrays.fill(res, -1);
        for (int i = 0; i < nums.length; i++) {
            if (res[index[i]] == -1) {
                res[index[i]] = nums[i];
            }else {
                for (int j = nums.length -1 ; j >= index[i]+1 ; j--) {
                    res[j] = res[j-1];
                }
                res[index[i]] = nums[i];
            }

        }
        return res;
    }

}
